<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>专业-组织架构</title>
</head>
<body>
    <table id="structure20210418"></table>
    <div id="tb_structure20210418_dg" style="padding:2px 5px;">
        <a href="javascript:" class="easyui-linkbutton" iconCls="icon-add" plain="true" >添加</a>
        <a href="javascript:" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
        <a href="javascript:" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
    </div>
    <script>
      $('#structure20210418').treegrid({
        method:'get',
        url:'./../structure/queryTreeAll',
        idField:'id',
        animate: true,
        treeField:'text',
        fit:true,
        fitColumns:true,
        rownumbers:true,
        columns:[[
          {field:'text',title:'名称',width:160},
          {field:'createTime',title:'创建时间',width:80,
              formatter: function(value,row,index){
                  return timeStamp2String(value);
              }
          },
          {field:'state',title:'节点状态',width:80,
              formatter: function(value,row,index){
                if(value == 'open'){
                    return value;
                }
                return 'closed';
              }
          },
          {field:'status',title:'状态',width:80},
          {field:'remarks',title:'备注',width:80}
        ]],
        toolbar:'#tb_structure20210418_dg'
      });

      function timeStamp2String(time){
          let datetime = new Date(time);
          let year = datetime.getFullYear();
          let month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
          let date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
          let hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();
          let minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
          let second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
          return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second;
      }
    </script>
</body>
</html>